def getCommandsForItem(actor,itemOrGhost):
    commands = []
    for verb in itemOrGhost.verbs:
        commands.append(Command(verb,actor,itemOrGhost.ID))
    return commands

class Command:
    def __init__(self,verb,actor=None,itemID=None,target=None):
        self.verb = verb
        self.actor = actor
        self.itemID = itemID
        self.target = target
    
    def doIt(self):
        self.verb.doIt(self.actor,self.fetchItem(),self.target)
    
    def calculateAP(self):
        return self.verb.calculateAP(self.actor,self.fetchItem(),self.target)
    
    def isPossible(self):
        return self.verb.isPossible(self.actor,self.fetchItem(),self.target)
    
    def fetchItem(self):
        if self.itemID:
            return self.actor.findItem(self.itemID)
        else:
            return None
    
    def __getattr__(self,name):
        return getattr(self.verb,name)
